﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using Microsoft.Practices.Prism.Modularity;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Prism.UnityExtensions;
using Hockey.GameEngine;
using Hockey.UILayer;
using Hockey.ViewModels;
using Hockey.Engine;
using MVVMDialogs;
using Hockey.Shared;
using Microsoft.Practices.Prism.Events;


namespace Hockey
{
    public class Bootstrapper : UnityBootstrapper
    {
        protected override DependencyObject CreateShell()
        {
            // register dialog service
            this.Container.RegisterInstance<IWindowViewModelMappings>(this.Container.Resolve<WindowViewModelMappings>());
            this.Container.RegisterInstance<IDialogService>(this.Container.Resolve<DialogService>());

            return this.Container.Resolve<MainWindow>();
        }

        protected override void InitializeShell()
        {
            base.InitializeShell();

            App.Current.MainWindow = (Window)this.Shell;
            App.Current.MainWindow.Show();
        }

        protected override void ConfigureModuleCatalog()
        {
            base.ConfigureModuleCatalog();

            ModuleCatalog moduleCatalog = (ModuleCatalog)this.ModuleCatalog;
            moduleCatalog.AddModule(typeof(GameEngineModule));
            moduleCatalog.AddModule(typeof(EngineModule));           
            moduleCatalog.AddModule(typeof(UILayerModule));

        }

        protected override void InitializeModules()
        {
            base.InitializeModules();

            // init shell viewmodel
            MainViewModel vm = this.Container.Resolve<MainViewModel>();
            App.Current.MainWindow.DataContext = vm;
        }
    }
}
